import {request} from "@/utils/http";
import type {LoginWithAccountType, LoginWithPhoneType, RegisterType} from "@/types/user";

const token: string = "login token"
export const loginWithPhone = (form: LoginWithPhoneType) => {
    return request<string>({
        url: '/auth/login/phone',
        method: 'POST',
        data: form,
        header: {
            "App-Channel": "MP"
        }
    })
}
export const loginWithAccount = (form: LoginWithAccountType) => {
    return request<string>({
        url: '/auth/login/account',
        method: 'POST',
        data: form
    })
}
/**
 * 获取手机号验证码
 * @param phone
 */
export const requireCode = (phone: string) => {
    return request<string>({
        url: '/auth/require-code?phone=' + phone,
        method: 'GET'
    })
}
export const resetPasswd = (form: RegisterType) => {
    return request<string>({
        url: '/auth/reset-passwd',
        method: 'POST',
        data: form
    })
}
export const registerUser = (form: RegisterType) => {
    return request<string>({
        url: '/auth/register',
        method: 'POST',
        data: form,
        header: {
            "App-Channel": "MP"
        }
    })
}